package io.gitee.zhangbinhub.acp.boot.socket

import io.gitee.zhangbinhub.acp.boot.init.AcpInitialization
import io.gitee.zhangbinhub.acp.boot.log.LogAdapter
import io.gitee.zhangbinhub.acp.boot.socket.conf.AcpTcpServerConfiguration
import io.gitee.zhangbinhub.acp.boot.socket.conf.AcpUdpServerConfiguration
import io.gitee.zhangbinhub.acp.boot.socket.init.AcpSocketServerInitialization
import io.gitee.zhangbinhub.acp.boot.socket.init.task.InitTcpServer
import io.gitee.zhangbinhub.acp.boot.socket.init.task.InitUdpServer
import org.noear.solon.annotation.Bean
import org.noear.solon.annotation.Configuration
import org.noear.solon.annotation.Import
import org.noear.solon.annotation.Inject

@Configuration
@Import(AcpTcpServerConfiguration::class, AcpUdpServerConfiguration::class)
class AcpSocketAutoConfiguration {
    @Bean(index = 1)
    fun acpSocketServerInitialization(
        @Inject logAdapter: LogAdapter,
        @Inject acpTcpServerConfiguration: AcpTcpServerConfiguration,
        @Inject acpUdpServerConfiguration: AcpUdpServerConfiguration
    ): AcpInitialization = AcpSocketServerInitialization(
        InitTcpServer(logAdapter, acpTcpServerConfiguration),
        InitUdpServer(logAdapter, acpUdpServerConfiguration)
    )
}